package org.ipb.controller.modul.agendapimpinan;

import java.sql.Timestamp;

import org.ipb.model.AgendaPimpinan;
import org.ipb.model.JabatanStrukturalPegawai;

import util.hibernate.DAO;

import com.opensymphony.xwork2.ActionSupport;

public class ActionCrud extends ActionSupport {
	private static final long serialVersionUID = -5933849517817526086L;
	private int id;
	private String namaKegiatan;
	private String lokasiKegiatan;
	private String ruangKegiatan;
	private Timestamp dari;
	private Timestamp sampai;
	private String keterangan;
	private String kodeWarna;
	private String pejabatStrukturalId;
	private String nextPage;
	public String getNextPage() {
		return nextPage;
	}

	public void setNextPage(String nextPage) {
		this.nextPage = nextPage;
	}

	public String insert() {
		DAO<Integer> dao = new DAO<Integer>();
		AgendaPimpinan object = new AgendaPimpinan();
		object.setDari(getDari());
		object.setSampai(getSampai());
		object.setKeterangan(getKeterangan());
		object.setRuangKegiatan(getRuangKegiatan());
		object.setNamaKegiatan(getNamaKegiatan());
		object.setLokasiKegiatan(getLokasiKegiatan());
		object.setKodeWarna(getKodeWarna());
		JabatanStrukturalPegawai jsp = new JabatanStrukturalPegawai();
		jsp.setId(Integer.valueOf(getPejabatStrukturalId()));
		object.setPejabatStruktural(jsp);
		dao.insert(object);
		dao.close();
		nextPage = "undanganpimpinan";
		return "next";
	}

	public String update() {
		DAO<Integer> dao = new DAO<Integer>();
		AgendaPimpinan object = (AgendaPimpinan) dao.find(AgendaPimpinan.class,
				Integer.valueOf(getId()));

		dao.update(object);
		dao.close();
		return "empty";
	}

	public String delete() {
		DAO<Integer> dao = new DAO<Integer>();
		AgendaPimpinan delete = (AgendaPimpinan) dao.find(AgendaPimpinan.class,
				Integer.valueOf(getId()));
		dao.delete(delete);
		dao.close();
		return "empty";
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNamaKegiatan() {
		return namaKegiatan;
	}

	public void setNamaKegiatan(String namaKegiatan) {
		this.namaKegiatan = namaKegiatan;
	}

	public String getLokasiKegiatan() {
		return lokasiKegiatan;
	}

	public void setLokasiKegiatan(String lokasiKegiatan) {
		this.lokasiKegiatan = lokasiKegiatan;
	}

	public String getRuangKegiatan() {
		return ruangKegiatan;
	}

	public void setRuangKegiatan(String ruangKegiatan) {
		this.ruangKegiatan = ruangKegiatan;
	}

	public Timestamp getDari() {
		return dari;
	}

	public void setDari(Timestamp dari) {
		this.dari = dari;
	}

	public Timestamp getSampai() {
		return sampai;
	}

	public void setSampai(Timestamp sampai) {
		this.sampai = sampai;
	}

	public String getKeterangan() {
		return keterangan;
	}

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	public String getKodeWarna() {
		return kodeWarna;
	}

	public void setKodeWarna(String kodeWarna) {
		this.kodeWarna = kodeWarna;
	}

	

	public String getPejabatStrukturalId() {
		return pejabatStrukturalId;
	}

	public void setPejabatStrukturalId(String pejabatStrukturalId) {
		this.pejabatStrukturalId = pejabatStrukturalId;
	}

}
